package c.j.a.c;

import android.util.Pair;
import c.j.a.b.a.c.a;
import c.j.a.c.g$g.d.c;
import c.j.a.c.g.y;
import c.j.a.c.o.b;
import c.j.a.c.q.d;
import c.j.a.c.y.a.i;
import java.util.Objects;
import org.json.JSONObject;

/* compiled from: AdDownloadCompletedEventHandlerImpl */
public class e implements Runnable {
    public final /* synthetic */ long a;

    public e(g gVar, long j) {
        this.a = j;
    }

    public void run() {
        g d = g.d();
        long j = this.a;
        Objects.requireNonNull(d);
        b bVar = b.b.a;
        try {
            a aVar = (a) c.a.e.get(Long.valueOf(j));
            if (aVar != null && !d.o(aVar)) {
                if (!aVar.J.get()) {
                    c.j.a.c.g$g.c.b bVar2;
                    int intValue;
                    Pair e = c.j.a.c.g$g.c.b().e(aVar);
                    if (e != null) {
                        bVar2 = (c.j.a.c.g$g.c.b) e.first;
                        intValue = ((Integer) e.second).intValue();
                    } else {
                        bVar2 = c.j.a.c.g$g.c.b().a(aVar);
                        intValue = -1;
                    }
                    if (bVar2 != null) {
                        c.j.a.c.g$g.c.b().g(bVar2.a);
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("installed_app_name", bVar2.d);
                        jSONObject.put("installed_pkg_name", bVar2.a);
                        if (intValue != -1) {
                            jSONObject.put("error_code", intValue);
                            y.f(jSONObject, aVar.q);
                            i.p(true);
                            bVar.n("install_finish_hijack", jSONObject, aVar);
                            return;
                        }
                        bVar.n("install_finish_may_hijack", jSONObject, aVar);
                    }
                }
            }
        } catch (Throwable th) {
            d.j(th);
        }
    }
}
